package com.jason.redis.test;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class RedisMain {

    public static void main(String[] args) {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8000));
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8001));
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8002));
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8003));
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8004));
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8005));
        jedisClusterNode.add(new HostAndPort("192.168.8.149", 8006));

        JedisCluster jedisCluster = new JedisCluster(jedisClusterNode, jedisPoolConfig);
        jedisCluster.set("user:5", "zhaosi");
        jedisCluster.set("user:6", "wangwu");
        System.out.println("添加成功");
        String value = jedisCluster.get("user:5");
        System.out.println("取值:" + value);

    }
}
